package com.itheima.reggie;

public class Thread3 {
    static Integer number = 0;
    public static void main(String[] args) {
        Run1 run1 = new Run1();
        Run2 run2 = new Run2();

        run1.setName("线程一号");
        run2.setName("线程二号");

        run1.start();
        run2.start();
    }
}
class Run1 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 200000; i++) {
            Thread3.number++;
        }
        System.err.println(Thread.currentThread().getName()+"对共享变量增加了"
        +Thread3.number+"次");
    }
}
class Run2 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 200000; i++) {
            Thread3.number++;
        }
        System.err.println(Thread.currentThread().getName() + "对共享变量增加了" + Thread3.number + "次");
    }
}
